using UnityEngine;
using UnityGameFramework.Runtime;
using LS.Saving;

namespace LS.SVariable
{
    public static class SavingAssociatedVariableExtensions
    {
        public static void ReadFromSaving(this SavingAssociatedVariable variable)
        {
            variable.SetValueWithoutNotification(LSEntry.Saving.GetObject(variable.SaveGroupName, variable.Name));
        }

        public static void SetToSaving(this SavingAssociatedVariable variable)
        {
            LSEntry.Saving.SetObject(variable.SaveGroupName, variable.Name, variable.RowValue);
        }
        
        public static void SetToDataNode(this SavingAssociatedVariable variable)
        {
            LSEntry.DataNode.SetData(variable.Name, variable);
        }
    }
}